﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SNSpirit.Domain.Rss
{
    internal class RssTracerWrapper
    {
        public static DateTime Now
        {
            get
            {
                return DateTime.UtcNow;
            }
        }

        public RssTracerWrapper(RssFeed feed)
        {
            if (feed == null)
                throw new ArgumentNullException("feed");
            this.Feed = feed;
            this.MoveNextTriggerTime();
        }

        public RssFeed Feed { get; set; }

        public DateTime TriggerTime { get; private set; }

        public bool IsUpdating { get; set; }

        public void MoveNextTriggerTime()
        {
            // Use utc now for better performance since utcnow don't require time zone info
            this.TriggerTime = DateTime.UtcNow + this.Feed.UpdateInterval;
        }
    }
}
